export default class Scann {
    constructor(template) {
        // 字符串
        this.template = template
        //初始值
        this.pos = 0
        //结束字符串
        this.endTemplate = template
    }
    //扫描文本
    scanUtils(stopTag) {
        //记录开始pos
        var st_pos = this.pos
        // 
        while (this.endTemplate.indexOf(stopTag) != 0 && this.eco()) {
            this.pos++
            this.endTemplate = this.template.substring(this.pos)
        }
        // console.log(this.template.substring(st_pos, this.pos))
        return this.template.substring(st_pos, this.pos)
    }
    //跳过
    scan(tag) {
        while (this.eco() && this.endTemplate.indexOf(tag) == 0) {
            this.pos += tag.length
            this.endTemplate = this.template.substring(this.pos)
        }
    }
    //停止扫描
    eco() {
        return this.pos < this.template.length
    }
}